<?php
class test{
     public $a=1;

    public  function test1(){
        $hello =function (){
            echo $this->a;
        };
        $hello();
    }
    public function test2($b){
        $b();
    }
    public function test3(){
        return new test();
    }
}

$test= new test();
$test->a=2;
echo $test->a;
echo $test->test3()->a;